﻿<!DOCTYPE HTML>
<html>
{include file="public:header_css"}
<body>
<nav class="breadcrumb">
	<i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 教师管理 <span class="c-gray en">&gt;</span> 教师列表
	<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container">
	<div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
            <a class="btn btn-primary radius" href="{:url('add')}">
				<i class="Hui-iconfont">&#xe600;</i> 新增教师
			</a>
		</span>
		<span class="r">共有：<strong>{$total}</strong> 条</span>
	</div>
	<form class="form-inline" role="form" method="get">
		<div id="" class="" style="float: right;margin-top: 20px;margin-bottom: 20px;">
			<label>姓名查找:
				<input type="search" class="input-text " value="{$teacher_name ? $teacher_name : '';}" style="width: 200px;" name="keywords" id="keywords" >
				<button class="btn btn-primary radius" type="submit" id="submit"  style="margin-top: -4px;">&nbsp;&nbsp;搜索&nbsp;&nbsp;</button>
				<button class="btn btn-warning radius" type="submit" id="reset"  style="margin-top: -4px;">&nbsp;&nbsp;置空&nbsp;&nbsp;</button>
			</label>
		</div>
	</form>

	<form class="form-inline" role="form" method="get">
		<div id="" class="" style="float: left;margin-top: 20px;margin-bottom: 20px;">
			<label>门店查找:
				<select style="width:40%;" class="input-text" id="keywords1" name="keywords1">
					<option value="0"  style="width:100%;">请点击选择</option>
					{foreach name="store_list" item="val" key="key"}
					<option value="{$val['store_id']}"  style="width:100%;" {if $keywords1==$val.store_id} selected {/if}>{$val['store_name']}</option>
					{/foreach}
				</select>
				<button class="btn btn-warning radius" type="submit" id="reset1"  style="float:right;margin-left:3px;">&nbsp;&nbsp;重置&nbsp;&nbsp;</button>
				<button class="btn btn-primary radius" type="submit" id="submit1"  style="float:right;">&nbsp;&nbsp;搜索&nbsp;&nbsp;</button>
			</label>
		</div>
	</form>

	<div class="mt-20">
		<table class="table table-border table-bordered table-bg table-sort">
			<thead>
			<tr class="text-c">
				<th width="60">教师编号</th>
				<th width="100">教师姓名</th>
				<th width="100">教师电话</th>
				<th width="80">性别</th>
				<th width="250">具体门店</th>
				<th width="250">操作</th>
			</tr>
			</thead>
			<tbody id="shopList">
			{foreach name="list" item="val" key="key"}
			<tr class="text-c">
				<td>{$val['teacher_id']}</td>
				<td>{$val['teacher_name']}</td>
				<td>{$val['teacher_tel']}</td>
				<td>{if condition="$val['sex'] eq  1"} 男
					{else /} 女
					{/if}
				</td>
				<td>{$val['store_name']}</td>
				<td class="f-14 product-brand-manage" id="use">

					{if condition="($val['openid'] == '')"}
						<span class="label label-success radius" onclick="bind('二维码','{:url('qrcode')}','{$val.teacher_id}','300','300')" >点击绑定</span>
					{else /}
						<span class="label label-danger radius" onClick="unbind('{$val.teacher_id}')" id="jiebang">点击解绑</span>
					{/if}

					<a class="label label-secondary radius" href="{:url('edit',array('teacher_id'=>$val['teacher_id']))}" style="margin-left: 20px">点击编辑</a>

					{if $val['can_use'] == 1}
						<span class="label label-success radius" onClick="is_use('{$val.teacher_id}',0)"  style="margin-left: 20px">点击冻结</span>
					{else /}
						<span class="label label-danger radius" onClick="is_use('{$val.teacher_id}',1)" style="margin-left: 20px">点击恢复</span>
					{/if}
				</td>
			</tr>
			{/foreach}
			{if count($list)<=0 }
			<tr class="text-c">
				<td colspan="10">
					暂无数据
				</td>
			</tr>
			{/if}
			</tbody>
		</table>
	</div>
	{$page}
</div>

{include file="public:footer_js"}

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__STATIC__/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/laypage/1.2/laypage.js"></script>

<script type="text/javascript">

	//绑定二维码
    function bind(title,url,id,w,h){

        //该id是教师id
        $.ajax({
            type   :"POST",
            url    :"{:url('bind')}",
            async  : true,
            data   :{ id : id},
            success: function(res){
                if(res.code){
                    layer_show(title,url,w,h);
                }
            }
        });
    }

    //解绑二维码
    function unbind(teacher_id) {
        var notice = "确定解绑吗？";
        //异步提交
        layer.confirm(notice,function (index) {
            $.ajax({
                type:"POST",
                url:"{:url('unbind')}",
                data:{
                    teacher_id    : teacher_id,
                },
                async:true,
                success:function (res) {
                    if(res.code === 1){
                        layer.msg(res.msg,{icon:6,time:1000});
                        //刷新可修改数据
                        setTimeout(function () {
                            location.replace(location.href);
							//$('#jiebang').html('已解绑');

                        },2000);

                    }else{
                        layer.msg(res.msg,{icon:5,time:1000});
                    }
                },
                error:function (res) {
                    console.log(res.data);
                }
            });

        })
    }

	//冻结还是正常
    function is_use(teacher_id,can_use) {
		var notice = "确定冻结吗？";
		if (can_use == 0){
            notice = "确定冻结吗？";
		}else if(can_use === 1){
            notice = "确定恢复吗？";
        }
        //异步提交
		layer.confirm(notice,function (index) {
            $.ajax({
                type:"POST",
                url:"{:url('is_use')}",
                data:{
                    teacher_id  : teacher_id,
                    can_use     : can_use
                },
                async:true,
                success:function (res) {
                    if(res.code === 1){
                        layer.msg(res.msg,{icon:6,time:1000});
						//刷新可修改数据
                        setTimeout(function () {
                            location.replace(location.href);
                        },2000);

                    }else{
                        layer.msg(res.msg,{icon:5,time:1000});
                    }
                },
				error:function (res) {
                    console.log(res.data);
                }
            });

        })
    }

    //姓名重置
    $('#reset').click(function () {
        $('#keywords').val('');
    })

    //门店重置
    $('#reset1').click(function () {
        $('#keywords1').val('');
    })


</script>
</body>
</html>